/* eslint-disable no-use-before-define */
/* eslint-disable import/extensions */
/* eslint-disable import/order */
/* eslint-disable import/no-unresolved */
import { createApp } from 'vue';
import ElementUI from 'element-plus';
import App from './App.vue';
import router from './router';
import store from './store';
import 'element-plus/dist/index.css';
// eslint-disable-next-line
import QfContainer from '@/components/Container.vue';
import companyPicker from '@/components/companyPicker.vue';
import VueMarkdownEditor from '@kangc/v-md-editor';
import '@kangc/v-md-editor/lib/style/base-editor.css';
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';

import Prism from 'prismjs';

import { regionDataPlus } from 'element-china-area-data';

VueMarkdownEditor.use(vuepressTheme, {
  Prism,
});

const app = createApp(App);
app.component('QfPage', QfContainer);
app.component('companyPicker', companyPicker);

app.mixin({
  methods: {
    formatArea(str: string | number) {
      const arr = str.split(',');
      // 省一级
      const province = regionDataPlus.find((item) => item.value === arr[0]);
      // 市一级
      const city = province.children.find((item) => item.value === arr[1]);
      // 区一级
      const zone = city.children.find((item) => item.value === arr[2]);
      return `${province.label}/${city.label}/${zone.label}`;
    },
  },
});

app.use(store);
app.use(router).mount('#app');
app.use(VueMarkdownEditor);
app.use(ElementUI);
